<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据双向绑定</title>
    <script src="../dist/sact.js"></script>
    <link rel="stylesheet" href="./main.css">
</head>

<body>
    <div id="root">
        <s-list></s-list>
        <s-list></s-list>
        <s-list></s-list>
    </div>
</body>



<script>
    let component = Sact.component({
        name: "s-list",
        template: `
            <div>
                <div s-for="item in list">
            我要 {{ item }}
            </div>
            <input s-model:value="input">
            <button @click="list.push(input)">添加</button>
        <div>
        `,
        data() {
            return {
                list: ["吃饭", "睡觉", "学习"],
                input: "",
            }
        }
    })
    Sact.link()
        .el("#root")
        .component({ component })
        .do;
</script>

</html>